{% import "macros/page.html" as page_macros %}
{% extends "base.html" %}

{% block title %}{{ trans(key="projects", lang=lang) }} - {{ config.title }}{% endblock title %}

{% block content %}
<main id="main" tabindex="-1">
    {% set project_categories = load_data(path="content/projects/categories." ~ lang ~ ".json", required=false) %}
    {% if not project_categories %}
        {% set project_categories = load_data(path="content/projects/categories.json") %}
    {% endif %}

    {% for category, tag in project_categories %}
        <h1>{{ category }}</h1>
        {% for page in section.pages %}
            {% if page.taxonomies.categories is containing(tag) %}
                {{ page_macros::project_listing(page=page) }}
            {% endif %}
        {% endfor %}
    {% endfor %}

    <h1>{{ trans(key="other", lang=lang) }}</h1>
    {% for page in section.pages %}
        {% if page.taxonomies.categories | length == 0 %}
            {{ page_macros::project_listing(page=page) }}
        {% endif %}
    {% endfor %}

</main>
{% endblock content %}
